﻿@import "colors";

.transition(@timeout, @prop) {
    -moz-transition: @timeout @prop;
    -o-transition: @timeout @prop;
    -webkit-transition: @timeout @prop;
    transition: @timeout @prop;
}

.border-box() {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.content-box {
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
}

.text-ellipsis() {
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    overflow: hidden;
    -ms-word-break: keep-all;
    word-break: keep-all;
    -ms-word-wrap: initial;
    word-wrap: initial;
}

.tinyselect-container {
    background-color: @con-bg;
    border: 1px solid @con-bd;
    height: auto;
    color: @con-fg;
    z-index: 99;
    .border-box();
    &:not(.tinyselect-mode-list) {
        position: absolute;
        border-top-width: 0;
        box-shadow: @con-sd 0 2px 4px 2px;
    }

    &.tinyselect-mode-list {
        height: 100%;
    }

    &.tinyselect-mode-dropdown {
        display: none;
        .content-box();
    }

    .tinyselect-box {
        overflow-y: auto;
        .tinyselect-item {
            .border-box();
            cursor: default;
            .text-ellipsis();
            border: 1px solid transparent;
            border-top-color: @item-bd;
            .transition(382ms, border-color);
            .transition(382ms, background-color);
            position: relative;
            padding: 0 5px;
            background-color: @item-bg;

            &-before {
                float: left;
            }
            &-text {
                float: left;
            }
            &-after {
                float: right;
            }
            &-hover {
                border-color: @item-hover-bd;
            }
            &-selected {
                color: @item-selected-fg;
                .tinyselect-item-after {
                    width: 16px;
                    height: 100%;
                    text-align: center;
                    &:after {
                        width: 13px;
                        height: 9px;
                        display: inline-block;
                        content: ' ';
                        background: url("./img/selected.png") no-repeat center center;
                    }
                }
            }
        }

        .tinyselect-group {
            display: block;
            padding: 5px;
            background-color: @group-bg;
            border-bottom: 1px solid @group-bd;
            border-left: 3px double @group-bd;
        }

        &-layout-grid {
            .tinyselect-item {
                float: left;

                &-selected {
                    border: solid 1px @grid-bd;
                }
            }
        }

        &-layout-table {
            overflow-y: auto;
            overflow-x: hidden;
            .tinyselect-table-proxy {
                width: 100%;
                border-collapse: collapse;
                display: table;
                .tinyselect-item {
                    display: table-row;
                    float: none;
                    border: none;

                    > * {
                        padding: 2px 5px;
                        float: none;
                        display: table-cell;
                        border: 1px solid @table-bd;
                        &:first-child {
                            border-left-width: 1px;
                        }
                        &:last-child {
                            border-right-width: 1px;
                        }
                    }
                    &:hover > * {
                        background-color: @table-hover-bg;
                    }
                }
            }
        }
    }

    .tinyselect-header {
        border-bottom: 1px solid @header-bd;
        .tinyselect-filter {
            border: none;
            width: 100%;
            height: 28px;
            padding: 0 2px;
            .border-box();
        }
    }
    .tinyselect-footer {
        font-size: smaller;
        padding: 2px 5px;
        border-top: 1px solid @footer-bd;
        &:after {
            content: ' ';
            clear: both;
            display: block;
        }
        &-left {
            display: block;
            float: left;
        }
        &-right {
            display: block;
            float: right;
        }
    }
    &-empty {
        .tinyselect-footer,
        .tinyselect-header {
            display: none !important;
        }
        .tinyselect-box {
            color: @empty-fg;
        }
    }
}

.tinyselect-context {
    .border-box();
    &-result {
        height: inherit;
        overflow-y: auto;
        .tinyselect-result-item {
            display: block;
            .text-ellipsis();
            max-width: 160px;
            min-width: 100px;
            text-align: center;
            margin: 2px 5px;
            background-color: @result-bg;
            color: @result-fg;
            float: left;
            height: 24px;
            line-height: 24px;
            &-text {
                display: block;
                max-width: 120px;
                min-width: 60px;
                .text-ellipsis();
                padding: 0 5px;
                float: left;
                height: 24px;
                line-height: 24px;
            }
            &-link {
                display: block;
                width: 24px;
                text-align: center;
                cursor: pointer;
                float: right;
                height: 24px;
                line-height: 23px;
                background: url("./img/remove.png") no-repeat center center;
            }
        }
    }
    &-with-arrow {
        .tinyselect-context-result {
            padding-right: 36px;
        }
        .tinyselect-context-arrow {
            position: absolute;
            right: 0;
            top: 0;
            width: 36px;
            height: 100%;
            background: url("./img/arrow.png") center center no-repeat;
            .transition(618ms, background-color);
        }
    }
    &.tinyselect-context-readonly {
        .tinyselect-result-item-link {
            background-color: @result-close-readonly-bg;
            cursor: initial;
        }
        &.tinyselect-context-with-arrow .tinyselect-context-arrow {
            background-color: @result-arrow-readonly-bg;
        }
    }
    &:not(.tinyselect-context-readonly) {
        .tinyselect-result-item-link {
            background-color: @result-close-bg;
            cursor: pointer;
            &:hover {
                background-color: @result-close-hover-bg;
            }
        }
        &.tinyselect-context-with-arrow .tinyselect-context-arrow {
            background-color: @result-arrow-bg;
            cursor: pointer;
            &:hover {
                background-color: @result-arrow-hover-bg;
            }
        }
    }
}

.tinyselect-mask {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background-color: @mask-bg;
    z-index: 98;
    padding: 10px;
    .border-box();
}
